﻿// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_QC_IQC_ORDER_ITEM_DETAIL
// * CreateDate    : 2012/4/15 0:45:36
// * Creater       : CodeSmith
// * LastChangeDate: 2012/4/15 0:45:36
// * LastChanger   : 2012/4/15 0:45:36
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Chk
{
    /// <summary>
    /// QcIqcOrderItemDetail
    /// </summary>
    public partial class QcIqcOrderItemDetailBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objQcIqcOrderItemDetailEntity">Entity</param>
        /// <returns>Entity</returns>
        public static QcIqcOrderItemDetailEntity GetQcIqcOrderItemDetail(QcIqcOrderItemDetailEntity objQcIqcOrderItemDetailEntity)
        {
            return DataAccess.SelectSingle<QcIqcOrderItemDetailEntity>(objQcIqcOrderItemDetailEntity);
        }
        #endregion


        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objQcIqcOrderItemDetailEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertQcIqcOrderItemDetail(QcIqcOrderItemDetailEntity objQcIqcOrderItemDetailEntity)
        {
            return DataAccess.Insert(objQcIqcOrderItemDetailEntity);
        }

        public static bool InsertQcIqcOrderItemDetail(List<QcIqcOrderItemDetailEntity> objQcIqcOrderItemDetailEntityList)
        {
            return DataAccess.Insert(objQcIqcOrderItemDetailEntityList);
        }
        #endregion


        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objQcIqcOrderItemDetailEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateQcIqcOrderItemDetail(QcIqcOrderItemDetailEntity objQcIqcOrderItemDetailEntity)
        {
            return DataAccess.Update(objQcIqcOrderItemDetailEntity);
        }

        public static bool UpdateQcIqcOrderItemDetail(List<QcIqcOrderItemDetailEntity> objQcIqcOrderItemDetailEntityList)
        {
            return DataAccess.Update<QcIqcOrderItemDetailEntity>(objQcIqcOrderItemDetailEntityList);
        }
        #endregion


        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objQcIqcOrderItemDetailEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteQcIqcOrderItemDetail(QcIqcOrderItemDetailEntity objQcIqcOrderItemDetailEntity)
        {
            return DataAccess.Delete(objQcIqcOrderItemDetailEntity);
        }

        public static bool DeleteQcIqcOrderItemDetail(List<QcIqcOrderItemDetailEntity> objQcIqcOrderItemDetailEntityList)
        {
            return DataAccess.Delete<QcIqcOrderItemDetailEntity>(objQcIqcOrderItemDetailEntityList);
        }
        #endregion


        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetQcIqcOrderItemDetailAll()
        {
            return DataAccess.SelectAllDataSet<QcIqcOrderItemDetailEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<QcIqcOrderItemDetailEntity> GetQcIqcOrderItemDetailAllList()
        {
            return DataAccess.SelectAll<QcIqcOrderItemDetailEntity>();
        }
        #endregion

        #region Functions
        public static DataTable GetDtIqcOrderItemDetailByOrderID(string sOrderID)
        {
            string sql = @"select * from QC_IQC_ORDER_ITEM_DETAIL qioid
                where qioid.ORDER_ID='" + sOrderID+"' ";
            return DataAccess.SelectDataSet(sql).Tables[0];
        }

        /// <summary>
        /// 用于查询不良待退货记录
        /// </summary>
        public static DataTable GetDtNgDetailByOrderID(string sOrderID)
        {
            string sql = @"select qioid.*,qioi.ORDER_ITEM_ID,qioi.ARRIVED_ITEM_ID,mp.PRODUCT_NAME,mp.PRODUCT_CODE,mp.DESCRIPTION 
from QC_IQC_ORDER_ITEM_DETAIL qioid
left join QC_IQC_ORDER_ITEM qioi on qioid.ORDER_ITEM_ID=qioi.ORDER_ITEM_ID
left join PUR_PURCHASE_ARRIVED_ITEM ppai on qioi.ARRIVED_ITEM_ID=ppai.ARRIVED_ITEM_ID
left join PUR_PURCHASE_ORDER_ITEM ppoi on ppai.PURCHASE_ITEM_ID=ppoi.PURCHASE_ITEM_ID
left join MST_PRODUCT mp on ppoi.PRODUCT_ID=mp.PRODUCT_ID
where qioid.ORDER_ID='" + sOrderID + "'";
            return DataAccess.SelectDataSet(sql).Tables[0];
        }
        #endregion
    }


}

